package com.docker.sys.role;

import com.docker.core.constant.APPIDConstant;
import com.docker.core.constant.ConfigConstant;
import com.docker.core.mvc.APPID;
import com.docker.core.mvc.Remark;
import com.docker.core.mvc.controller.BaseAPIController;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Okv;
import com.jfinal.kit.PropKit;

/**
 * @Author ldl
 * @Create 2020/09/17 017 09:55
 */
@Remark("系统角色管理")
@APPID(APPIDConstant.dum_web)
public class RoleController extends BaseAPIController {

    @Inject
    private RoleService roleService;

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2020/09/18 018 09:35
     */
    @Remark("角色列表")
    public void list() {
        Okv cond = Okv.create()
                .set("r.status_flag = ", "1")
                .set("r.role_id != ", PropKit.get(ConfigConstant.SUPER_ADMIN_ROLE));
        renderAPISuccess(roleService.list(Okv.by("cond", cond).set("dept_code", getPara("dept_code"))));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2020/09/18 018 09:35
     */
    @Remark("新增角色")
    public void save() {
        renderAPI(roleService.save(getBean(RoleBean.class, ""), getUserId()));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2020/09/18 018 09:35
     */
    @Remark("修改角色")
    public void update() {
        renderAPI(roleService.update(getBean(RoleBean.class, ""), getUserId()));
    }

}
